package com.eastfair.projectcore.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 数据隔离表
 * </p>
 *
 * @author ligang
 * @date 2022-10-11
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "DataIsolationSystemTypeEnum", description = "系统类型#{COMMON:公共服务;BUSINESS:业务服务-枚举")
public enum DataIsolationSystemTypeEnum implements BaseEnum {

    /**
     * COMMON="公共服务"
     */
    COMMON("公共服务"),
    /**
     * BUSINESS="业务服务"
     */
    BUSINESS("业务服务"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static DataIsolationSystemTypeEnum match(String val, DataIsolationSystemTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static DataIsolationSystemTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(DataIsolationSystemTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "COMMON,BUSINESS", example = "COMMON")
    public String getCode() {
        return this.name();
    }

}
